<template>
	<view class="contents">
		<view class="" style="border-left: 3px solid #1262DB;padding-left: 20rpx;font-weight: bold;">
			已有设备
		</view>
		
		<view class="" v-for="(item,index) in datalist" style="padding: 20rpx;border-radius: 20rpx;box-shadow: 2px 2px 5px 5px #ececec;margin-top: 30rpx;display: flex;flex-direction: column;">
			<view class="" style="display: flex;justify-content: space-between;align-items: center;">
				<view class="">
					状态：<text style="color: green;" v-if="item.is_online == 1">在线</text><text style="color: #666666;" v-else>离线</text>
				</view>
				<view class="">
					<switch :disabled="true" :checked="item.is_online == 1 ? true : false" color="#FFCC33" style="transform:scale(0.7)"/>
				</view>
			</view>
			<view class="xian">
				
			</view>
			<view class="" style="margin-top: 10rpx;color: #909090;font-size: 28rpx;">
				设备编号:{{item.no_number}}
			</view>
			<view class="" style="margin-top: 10rpx;color: #909090;font-size: 28rpx;">
				设备押金:{{item.deposit}}
			</view>
			<view class="" style="margin-top: 10rpx;color: #909090;font-size: 28rpx;">
				备注:{{item.title}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				datalist:[]
			}
		},
		onLoad() {
			this.getdata()
		},
		methods: {
			getdata(){
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				uni.request({
					url: this.global.url + 'api/device/device_list',
					method: 'POST',
					data: {
						clinic_id: uni.getStorageSync('clinic_id')
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							// 存用户信息
							that.datalist = result.data
							
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'none'
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				})
			}
		}
	}
</script>

<style>
.contents{
	padding: 30rpx;
}
.xian{
	border-bottom: 1px solid #ececec;
}
</style>
